package com.ezzd.controller;

import com.ezzd.pojo.TbOrders;
import com.ezzd.service.OrdersService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @description tb_orders
 * @author 被遗忘的湫
 * @date 2022-08-05
 */
@RestController
@RequestMapping(value = "/orders")
public class OrdersController {

    @Resource
    private OrdersService ordersService;

    /**
     * 新增
     * @author 被遗忘的湫
     * @date 2022/08/05
     **/
    @RequestMapping("/insert")
    public Object insert(TbOrders tbOrders){
        return ordersService.insert(tbOrders);
    }

    /**
     * 刪除
     * @author 被遗忘的湫
     * @date 2022/08/05
     **/
    @RequestMapping("/delete/{id}")
    public Object delete(@PathVariable("id") int id){
        return ordersService.delete(id);
    }

    /**
     * 更新
     * @author 被遗忘的湫
     * @date 2022/08/05
     **/
    @RequestMapping("/update")
    public Object update(TbOrders tbOrders){
        return ordersService.update(tbOrders);
    }

    /**
     * 查询 根据主键 id 查询
     * @author 被遗忘的湫
     * @date 2022/08/05
     **/
    @RequestMapping("/load")
    public Object load(int id) {
        return ordersService.load(id);
    }

    /**
     * 查询 分页查询
     * @author 被遗忘的湫
     * @date 2022/08/05
     **/
    @RequestMapping("/list")
    public Object pageList(@RequestParam(required = false, defaultValue = "1") int pageNum,
                           @RequestParam(required = false, defaultValue = "10") int pagesize) {
            return ordersService.pageList(pageNum, pagesize);
    }

}
